<script type="text/javascript">
$("#license_success_modal").parents(".modal-dialog").css("min-width", 577);
/*function submit_license_create(){  
    angular.element('#license_open_button').scope().close("/license/create/upload"); 
    angular.element('#license_open_button').scope().open("/license/create/message"); 
    alert("zzz");
}*/
function license_success_ok() {
  var form_validation = true;
  var bValid = true;

  $('.rtn-tip').hide();
  var filename = $('#license_file').val();
  var fileType = filename.substring(filename.lastIndexOf('.') + 1);

  if(!($('#license_file').val())) {
    $('.rtn-tip').text('请选择一个文件。').slideDown();
    return;
  }
  if(fileType !== 'tar') {
    $('.rtn-tip').text('文件名的格式应为*.tar。').slideDown();
    return;
  }
  $(".success_license_btn").css("display", "none");
  $(".activated_state").css("display", "block");
  if (bValid) {
    if (form_validation) {
      form_validation = false;
      $(".register_submit").ajaxSubmit({
        type: 'post',
        url: "/license/upload",
        success: function(data) {
          if (data.reply.is_success) {
            angular.element('#license_open_button').scope().close("/license/create/success");
          } else {
            var error = data.reply.error;
            $(".rtn-tip").text(error).slideDown();
            $(".success_license_btn").css("display", "block");
            $(".activated_state").css("display", "none");
          }
        },
        error: function(a, XmlHttpRequest, textStatus, errorThrown) {
          form_validation = true;
        }
      })
    }
  }
}
var upload_modal = $("#license_upload_modal");
var upload_src = upload_modal.find(".upload_button");
$("#upload_isrc").html(upload_src.attr("href"));
$(".add_file_button").click(function() {
  input_file = '<input type="file" id="license_file" name="license_file"  style="width:420px;border:1px solid #d8dce5;margin:3px;float:left"/><a style="float:right" class="delete_file" title="删除">&nbsp; </a><br>'
  $('.register_submit').append(input_file)
})

function success_license_home() {
  angular.element('#license_open_button').scope().close("/license/create/message");
  angular.element('#license_open_button').scope().open("/license/create/home");
}
</script>
<style>
  .rtn-tip{
    background-color: #ED7441;
    font-size: 14px;
    color: #fff;
    border-radius: 3px !important;
    display: none;
    padding: 3px 10px;
  }
</style>
<div class="modal-header">
  <h3>激活申请</h3>
  <i id="close_icon" ng-click="cancel()" class="fa fa-times"></i>
  <iframe name="I1" style="display:none"></iframe>
</div>
<div class="modal-body modal-body-height" id="license_success_modal">
  <div class="license_success_box">
    <div class="rtn-tip"></div>
    <div id="license_success_button" ng-controller="LicenseModalCtrl"></div>
    <span class="success_title_">导入激活码</span>
    <p class="license_head_cpy" style="padding:0px;margin-top:7px;margin-bottom:20px;">请选择激活码文件</p>
    <ul class="license_success_body">
      <li><span>文件：</span>
        <form method="POST" class="register_submit" enctype="multipart/form-data">
          <p class="upload_button" style="position:relative">
            <input type='text' name='textfield' id='textfield' class="p_input" />
            <a class="p_btn">浏览</a>
            <input type="file" name="license_file" class="p_btn license_input_file" id="license_file" size="28" onchange="document.getElementById('textfield').value=this.value" />
          </p>
        </form>
      </li>
    </ul>
  </div>
</div>
<div class="modal-footer license_footer">
  <div class="activated_state">
    激活中...
  </div>
  <button class="button button_gray butn-sub success_license_btn" ng-click="go_license_success()">确定</button>
  <button class="button button_gray butn-back" onclick="success_license_home()">返回</button>
</div>
